<template>
  <div class="module">
    <FileUploadComp :refId="refId" is-preview :type="['img']" biz-type="productList" :filter="filterData" :auto-upload="true" :showEdit="edit"  ref="FileUploadRef"></FileUploadComp>
  </div>
</template>

<script>
  import FileUploadComp from '../comp/FileUploadComp.vue'
export default {
  props: {
    edit: {
      type: Boolean,
      default: true
    },
    refId: {
      type: String,
      default: ''
    }
  },
  watch: {
    refId: {
      handler () {
        console.log('refId', this.refId)
        this.$nextTick(() => {
          if (this.$refs.FileUploadRef) {
              this.$refs.FileUploadRef.loadFiles()
            }
        })
      },
      immediate: true
    }
  },
  components: {FileUploadComp},
  methods: {
    filterData (data) {
      console.log('过滤数据')
      return data
    },
   async saveImage () {
      if (this.$refs.FileUploadRef) {
          await this.$refs.FileUploadRef.uploadFile({
            refId: this.refId,
            type: 'productList'
          })
        }
    }
  }
}
</script>

<style lang="scss" scoped>
.module {
  min-height: 470px;
}

</style>